package cn.qqtheme.framework.picker;

import android.app.Activity;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.qqtheme.framework.widget.WheelView;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes.dex */
public class DoublePicker extends WheelPicker {
    private List<String> firstData;
    private CharSequence firstPrefixLabel;
    private CharSequence firstSuffixLabel;
    private OnPickListener onPickListener;
    private OnWheelListener onWheelListener;
    private List<String> secondData;
    private CharSequence secondPrefixLabel;
    private CharSequence secondSuffixLabel;
    private int selectedFirstIndex;
    private int selectedSecondIndex;

    /* loaded from: classes.dex */
    public interface OnPickListener {
        void onPicked(int i, int i2);
    }

    /* loaded from: classes.dex */
    public interface OnWheelListener {
        void onFirstWheeled(int i, String str);

        void onSecondWheeled(int i, String str);
    }

    public DoublePicker(Activity activity, List<String> list, List<String> list2) {
        super(activity);
        this.firstData = new ArrayList();
        this.secondData = new ArrayList();
        this.selectedFirstIndex = 0;
        this.selectedSecondIndex = 0;
        this.firstData = list;
        this.secondData = list2;
    }

    public void setSelectedIndex(int i, int i2) {
        if (i >= 0 && i < this.firstData.size()) {
            this.selectedFirstIndex = i;
        }
        if (i2 < 0 || i2 >= this.secondData.size()) {
            return;
        }
        this.selectedSecondIndex = i2;
    }

    public void setFirstLabel(CharSequence charSequence, CharSequence charSequence2) {
        this.firstPrefixLabel = charSequence;
        this.firstSuffixLabel = charSequence2;
    }

    public void setSecondLabel(CharSequence charSequence, CharSequence charSequence2) {
        this.secondPrefixLabel = charSequence;
        this.secondSuffixLabel = charSequence2;
    }

    public String getSelectedFirstItem() {
        int size = this.firstData.size();
        int i = this.selectedFirstIndex;
        return size > i ? this.firstData.get(i) : "";
    }

    public String getSelectedSecondItem() {
        int size = this.secondData.size();
        int i = this.selectedSecondIndex;
        return size > i ? this.secondData.get(i) : "";
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // cn.qqtheme.framework.popup.ConfirmPopup
    public View makeCenterView() {
        LinearLayout linearLayout = new LinearLayout(this.activity);
        linearLayout.setOrientation(0);
        linearLayout.setGravity(17);
        if (!TextUtils.isEmpty(this.firstPrefixLabel)) {
            TextView createLabelView = createLabelView();
            createLabelView.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
            createLabelView.setText(this.firstPrefixLabel);
            linearLayout.addView(createLabelView);
        }
        WheelView createWheelView = createWheelView();
        createWheelView.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
        linearLayout.addView(createWheelView);
        if (!TextUtils.isEmpty(this.firstSuffixLabel)) {
            TextView createLabelView2 = createLabelView();
            createLabelView2.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
            createLabelView2.setText(this.firstSuffixLabel);
            linearLayout.addView(createLabelView2);
        }
        if (!TextUtils.isEmpty(this.secondPrefixLabel)) {
            TextView createLabelView3 = createLabelView();
            createLabelView3.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
            createLabelView3.setText(this.secondPrefixLabel);
            linearLayout.addView(createLabelView3);
        }
        WheelView createWheelView2 = createWheelView();
        createWheelView2.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
        linearLayout.addView(createWheelView2);
        if (!TextUtils.isEmpty(this.secondSuffixLabel)) {
            TextView createLabelView4 = createLabelView();
            createLabelView4.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
            createLabelView4.setText(this.secondSuffixLabel);
            linearLayout.addView(createLabelView4);
        }
        createWheelView.setItems(this.firstData, this.selectedFirstIndex);
        createWheelView.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DoublePicker.1
            @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
            public void onSelected(int i) {
                DoublePicker.this.selectedFirstIndex = i;
                if (DoublePicker.this.onWheelListener != null) {
                    DoublePicker.this.onWheelListener.onFirstWheeled(DoublePicker.this.selectedFirstIndex, (String) DoublePicker.this.firstData.get(DoublePicker.this.selectedFirstIndex));
                }
            }
        });
        createWheelView2.setItems(this.secondData, this.selectedSecondIndex);
        createWheelView2.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DoublePicker.2
            @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
            public void onSelected(int i) {
                DoublePicker.this.selectedSecondIndex = i;
                if (DoublePicker.this.onWheelListener != null) {
                    DoublePicker.this.onWheelListener.onSecondWheeled(DoublePicker.this.selectedSecondIndex, (String) DoublePicker.this.secondData.get(DoublePicker.this.selectedSecondIndex));
                }
            }
        });
        return linearLayout;
    }

    @Override // cn.qqtheme.framework.popup.ConfirmPopup
    public void onSubmit() {
        OnPickListener onPickListener = this.onPickListener;
        if (onPickListener != null) {
            onPickListener.onPicked(this.selectedFirstIndex, this.selectedSecondIndex);
        }
    }

    public void setOnWheelListener(OnWheelListener onWheelListener) {
        this.onWheelListener = onWheelListener;
    }

    public void setOnPickListener(OnPickListener onPickListener) {
        this.onPickListener = onPickListener;
    }
}
